package Charpter01;
import java.util.Scanner;
//先定义一个方法，完成功能
public class Charpter_Exception01 {
    static float sum;
    static float Calculate_Sum(float a,char b,float c)
                throws ArithmeticException,NumberFormatException{
        switch(b)
        {
            case '*':
                sum = a*c;
                break;
            case '/':
                sum =a/c;
                break;
            case '+':
                sum = a+c;
                break;
            case '-':
                sum = a-c;
                break;
            default:
                throw new ArithmeticException("出现异常 ");

        }
        return sum;

    }
    public static void main(String[] args)
    {
        float sum1,sum2,tatol;
        char ch;
        Scanner in = new Scanner(System.in);
        try{
            sum1 = in.nextFloat();
            sum2 =in.nextFloat();
            ch = in.next().charAt(0);
            tatol = Calculate_Sum(sum1,ch,sum2);
            System.out.print("值为"+tatol);
        }catch (NumberFormatException e) {
            System.out.println(" 输入的数字错误 ");

        }catch (ArithmeticException e){
            System.out.println("出现异常");
        }catch(ArrayIndexOutOfBoundsException e){
            System.out.println("你没有输入数据");
        }finally {
            System.out.println(" 谢谢使用");
        }

    }

}
